//
//  TZVideoTipViewHUD.m
//  PhotographVideoRecording
//
//  Created by 阿飞 on 2020/4/27.
//  Copyright © 2020 阿飞. All rights reserved.
//

#import "TZVideoTipViewHUD.h"

@implementation TZVideoTipViewHUD
- (instancetype)init
{
    self = [super init];
    if (self) {
        [self createUI];
    }
    return self;
}

- (void)createUI
{
    self.frame = [UIScreen mainScreen].bounds;
    UIView *mainView = [[UIView alloc]initWithFrame:self.frame];
    [self addSubview:mainView];
    
    UIView *layerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 150)];
    layerView.layer.masksToBounds = YES;
    layerView.layer.cornerRadius = 5.0f;
    layerView.backgroundColor = [UIColor whiteColor];
    layerView.center = self.center;
    [mainView addSubview:layerView];
    
    UILabel *tipLabel= [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 280, 90)];
    tipLabel.textAlignment = NSTextAlignmentCenter;
    tipLabel.textColor = [UIColor blackColor];
    tipLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:16];
    tipLabel.text = @"分享视频不能超过5分钟";
    [layerView addSubview:tipLabel];
    
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 90, 280, 0.5)];
    lineView.backgroundColor = [UIColor colorWithRed:198/255.0 green:198/255.0 blue:200/255.0 alpha:1.0];
    [layerView addSubview:lineView];
    
    UIButton *knowButton = [UIButton buttonWithType:UIButtonTypeCustom];
    knowButton.frame = CGRectMake(0, 91, 280, 59);
    [knowButton setTitle:@"我知道了" forState:UIControlStateNormal];
    [knowButton setTitleColor:[UIColor colorWithRed:131/255.0 green:200/255.0 blue:184/255.0 alpha:1.0] forState:UIControlStateNormal];
    knowButton.titleLabel.font = [UIFont systemFontOfSize:16];
    [knowButton addTarget:self action:@selector(dismissView) forControlEvents:UIControlEventTouchUpInside];
    [layerView addSubview:knowButton];
}
- (void)show
{
    [[UIApplication sharedApplication].keyWindow addSubview:self];

}
- (void)dismissView{
    
    [self hide];
}
- (void)hide
{
    dispatch_async(dispatch_get_main_queue(), ^{
        [self removeFromSuperview];
    });
}

@end
